<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>视频列表</title>
    <% include("../layout/css.html"){} %>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格顶部工具栏 -->
            <div class="layui-form toolbar">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">名字：</label>
                        <div class="layui-input-inline mr0">
                            <input name="name" class="layui-input" type="text" placeholder="请输入名字"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label w-auto">类别：</label>
                        <div class="layui-input-inline mr0" style="min-width: 200px;">
                            <input name="type" class="layui-input" type="text" placeholder="请输入类别"/>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn" lay-filter="searchSubmit" lay-submit>
                            <i class="layui-icon">&#xe615;</i>搜索
                        </button>
                    </div>
                </div>
            </div>

            <table class="layui-table" id="videoTable" lay-filter="videoTable"></table>
        </div>
    </div>
</div>

<!-- 表格操作列 -->
<script type="text/html" id="tableBar">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">查看</a>
</script>

<!-- js部分 -->
<% include("../layout/js.html"){} %>
<script>
    layui.use(['layer', 'form', 'table', 'util', 'laydate', 'tableX','index'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var tableX = layui.tableX;
        var index = layui.index;

        // 渲染表格
        var insTb = tableX.render({
            elem: '#videoTable',
            url: '/video/find',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'numbers'},
                {field: 'name', title: '名称', sort: true},
                {field: 'type', title: '类别', sort: true},
                {field: 'url', title: '路径', sort: true},
                {align: 'center', toolbar: '#tableBar', title: '操作', width: 200, minWidth: 200}
            ]]
        });


        // 搜索
        form.on('submit(searchSubmit)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}});
        });


        // 工具条点击事件
        table.on('tool(videoTable)', function (obj) {
            var data = obj.data.id;
            showEditModel(data);
        });

        function showEditModel(data) {
            index.openTab({
                title: '播放',
                url: 'video/detail?id='+data,
                end: function() {
                    // insTb.reload();
                }
            });
        }

    });
</script>
</body>
</html>
